<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <base href="${request.contextPath}/"/>
    <meta charset="UTF-8">
    <meta name="Keywords" content="">
    <meta name="Description" content="">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0,minimum-scale=1.0">
    <title>漠河智慧社区</title>
    <link href="Content/wechat/css/reset.css" rel="stylesheet" type="text/css">
    <link href="Content/wechat/css/shengHuo_QCSJ.css" rel="stylesheet" type="text/css">

    <script src="Content/wechat/js/jquery.min.js"></script>
    <!--字体缩放-->
    <script src="Content/wechat/js/ziti.js"></script>
    <!--end 字体缩放-->
    <!--页码js-->
    <script src="Content/wechat/js/myPagination.js"></script>
    <!--页码-->
    <link href="Content/wechat/css/myPagination.css" rel="stylesheet" type="text/css">
    <style type="text/css">
        .qyml_l_box{
            float: left;
            width: 30%;
        }
        .qyml_l_wenzi{
            float: left;
            width: 63%;
        }
        .nowrap {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .qyml_l_wenzi_xx{
            width: 100%;
        }
        .qyml_l_wenzi_xx i{
            float: left;
            display: inline-block;
            width: 0.3rem;
            height: 0.3rem;

        }
        .qyml_l_wenzi .qyml_l_wenzi_xx i img{
            width: 100%;
            vertical-align: middle;


        }
        .qyml_l_wenzi_xx p{
            font-size: 0.24rem;
            color: #949494;
            padding: 0.08rem 0;
        }
    </style>
</head>
<body>
<!--header-->
<header>
    <img src="Content/wechat/images/qcsj.jpg">
</header>
<!--end  header-->
<!--搜索-->
<div class="search">
    <div class="search_box">
        <span class="s_con"><input type="text" class="content" placeholder="请输入搜索内容" id="sname"><i class="clear"></i></span>
        <span class="s_btn">搜索</span>
    </div>
</div>

<script type="text/javascript">
    $('.content').on('keyup', function () {
        $('.clear').show();
    });
    $('.clear').click(function () {
        $('.content').val('');
    });
</script>
<!--end搜索-->
<div class="tuBiao_up clearfix" id="shoptype">
    <a class="a_icon" target="_self">
        <img src="Content/wechat/images/qcsj_1.png">
        <span>餐饮</span>
    </a>

    <!--    <a class="a_icon" href="#" target="_self">-->
    <!--        <img src="Content/wechat/images/qcsj_28.png">-->
    <!--        <span>其他</span>-->
    <!--    </a>-->

</div>
<div>
    <div id="shoplist">
        <div class="qyml clearfix">
            <div class="qyml_l">
                <div class="qyml_l_img">
                    <img src="Content/wechat/images/sq.jpg" onerror=src="Content/wechat/images/sq.jpg">
                </div>
                <div class="qyml_l_wenzi">
                    <h3>漠河北区公安局</h3>
                    <p>
                        <i>
                            <img src="Content/wechat/images/weizhi.png">
                        </i>
                        北大加油5-2号</p>
                    <b id="txt" class="txx" data-value="1111" onclick="shoucang();"></b>
                </div>


            </div>
            <div class="qyml_r">
                <a>
                    <img src="Content/wechat/images/tel_01.png">
                </a>
            </div>
        </div>
    </div>
    <div id="pagination" class="pagination"></div>
</div>
<!--加入收藏js-->
<script type="text/javascript">
    // var txt = document.getElementById('txt');
    // txt.onclick = function () {
    //     //alert('123')
    //     txt.style.backgroundColor = 'red'
    // }
    function shoucang(obj){
        //var obj=this;
        var shopid = obj.getAttribute("data-value");
        $.ajax({
            url: "/wechat/personage/collection/savecollection",
            type: 'post',
            dataType: 'json',
            data: {
                shopid: shopid
            },
            success: function (result) {
                if(result.data == "ok"){
                    obj.style.backgroundColor = 'red'
                }else{
                    alert("收藏失败！");
                }
            }
        })
    }



</script>
<!--end加入收藏js-->


</body>
<script>
    window.onload = function () {
        findshoptypeList();
        InitAjax(1);
    }

    function findshoptypeList() {
        $.ajax({
            url: "/wechat/home/life/qcsj/findshoptypeList",
            type: 'post',
            dataType: 'json',
            success: function (result) {
                //console.log(result.data);
                var zhinanData = ""; //视图数据
                $.each(result.data, function (index, items) {
                    var index2=index+1;
                    zhinanData += "  <a class=\"a_icon\" target=\"_self\" onclick=\"qurytype('" + items.id + "');\">\n" +
                        "        <img src=\"" + items.imgurl + "\" onerror=src=\"Content/wechat/images/qcsj_" + index2 + ".png\">\n" +
                        "        <span>" + items.shopname + "</span>\n" +
                        "    </a>";

                });
                $("#shoptype").html(zhinanData);

            }

        })
    }
</script>
<script>
    var pageTotal = 0;   //总页数
    var pageSize = 5;    //一页显示几个
    var sname="";
    var shoptype="";

    $(".s_btn").on("click", function () {
        sname=$("#sname").val();
        shoptype="";
        pageTotal = 0;
        InitAjax(1);
    });

    function qurytype(type){
        shoptype=type;
        sname="";
        pageTotal = 0;
        InitAjax(1);
    }



    function onLoadPaging() {
        new myPagination({
            id: 'pagination',
            curPage: 1, //初始页码
            pageTotal: pageTotal, //总页数
            pageAmount: pageSize,  //每页多少条
            pageSize: 2, //可选,分页个数

            getPage: function (page) {
                //获取当前页数
                InitAjax(page)
            }
        })
    }

    function InitAjax(pageNum) {
        $.ajax({
            url: "/wechat/home/life/shsm/findshopList",
            type: 'post',
            dataType: 'json',
            data: {
                pagination: "{page:\"" + pageNum + "\",rows:\"" + pageSize + "\",sidx:\"\",sord:\"\"}",
                sname: sname,
                shoptype: shoptype
            }, success: function (result) {
                ajaxCallBack(result);
            }

        })
    }

    function ajaxCallBack(data) {
        var insetViewData = ""; //视图数据
        $.each(data.data.rows, function (index, items) {

            // insetViewData += "<div class=\"qyml clearfix\">\n" +
            //     "            <div class=\"qyml_l\" onclick=\"window.location.href='/wechat/home/life/qcsj/affair_QCSJ_XQ?id="+items.id+"'\">\n" +
            //     "                <div class=\"qyml_l_img\">\n" +
            //     "                    <img src=\""+items.imgurl+"\" onerror=src=\"Content/wechat/images/sq.jpg\">\n" +
            //     "                </div>\n" +
            //     "                <div class=\"qyml_l_wenzi\">\n" +
            //     "                    <h3>"+items.sname+"</h3>\n" +
            //     "                    <p>\n" +
            //     "                        <i>\n" +
            //     "                            <img src=\"Content/wechat/images/weizhi.png\">\n" +
            //     "                        </i>\n" +
            //     // "                        "+items.communityname+items.villagename+items.buildingnumname+"</p>\n" +
            //     "                        地址："+items.buildingnumname+"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;电话："+items.sphone+"</p>\n" +
            //     "                    <b id=\"txt\" class=\"txx\" data-value=\""+items.id+"\"onclick=\"shoucang(this);\"></b>\n" +
            //     "                </div>\n" +
            //     "\n" +
            //     "\n" +
            //     "            </div>\n" +
            //     "            <div class=\"qyml_r\">\n" +
            //     "                <a href='tel:"+items.sphone+"'>\n" +
            //     "                    <img src=\"Content/wechat/images/tel_01.png\">\n" +
            //     "                </a>\n" +
            //     "            </div>\n" +
            //     "        </div>";

            insetViewData +="<div class=\"qyml clearfix\">\n" +
                "            <div class=\"qyml_l\" >\n" +
                "                <div class=\"qyml_l_box\" onclick=\"window.location.href='/wechat/home/life/qcsj/affair_QCSJ_XQ?id="+items.id+"'\">\n" +
                "                    <div class=\"qyml_l_img\">\n" +
                "                         <img src=\""+items.imgurl+"\" onerror=src=\"Content/wechat/images/sq.jpg\">\n" +
                "                    </div>\n" +
                "                </div>\n" +
                "                <div class=\"qyml_l_wenzi  \" >\n" +
                "                    <h3 class=\"nowrap\">"+items.sname+"</h3>\n" +
                "                    <div class=\"qyml_l_wenzi_xx clearfix\" onclick=\"window.location.href='/wechat/home/life/qcsj/affair_QCSJ_XQ?id="+items.id+"'\">\n" +
                "                        <p class=\"nowrap\">\n" +
                "                            <i>\n" +
                "                                <img src=\"Content/wechat/images/weizhi.png\">\n" +
                "                            </i>"+items.buildingnumname+"\n" +
                "                        </p>\n" +
                "                    </div>\n" +
                "                    <div class=\"qyml_l_wenzi_xx clearfix\" onclick=\"window.location.href='/wechat/home/life/qcsj/affair_QCSJ_XQ?id="+items.id+"'\">\n" +
                "                        <p class=\"nowrap\">\n" +
                "                            <i>\n" +
                "                                <img src=\"Content/wechat/images/tl.png\">\n" +
                "                            </i>"+items.sphone+"\n" +
                "                        </p>\n" +

                "                    </div>\n" +
                "                    <b id=\"txt\" class=\"txx\" data-value=\""+items.id+"\"onclick=\"shoucang(this);\"></b>\n" +
                "                </div>\n" +
                "            </div>\n" +

                "            <div class=\"qyml_r\">\n" +
                "                <a href='tel:"+items.sphone+"'>\n" +
                "                    <img src=\"Content/wechat/images/tel_01.png\">\n" +
                "                </a>\n" +
                "            </div>\n" +
                "        </div>";

        });
        $("#shoplist").html(insetViewData);
        if (pageTotal == 0) {
            pageTotal = data.data.total;
            onLoadPaging()
        }
    }


</script>
</html>